package com.yl.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import android.util.Log;


public class TimeUitl {
	private static final String TAG="日期时间处理类";
	/**
	 * 时间戳转换成普通日期型
	 * @param timestampString
	 * @return
	 */
	public static String TimeStamp2Date(Long timestamp){  
		  long temp = timestamp*1000;
//		  String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new java.util.Date(temp));
		  String date = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").format(new Date(temp));
		  return date;
	}
	
	/**
	 * 将时间字符串转换成时间戳
	 * @param stime
	 * @return
	 */
	public static long getTime(String stime){
		SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z",Locale.ENGLISH);
		
		Date sdate;
		long ltime = 0;
		String strtime;
		
		try{ 
			strtime = stime.trim();
			if(stime.length()==31 && stime!=null){
				sdate = sdf.parse(strtime); 
				ltime = sdate.getTime(); 
			}
		} catch (Exception e) {
			Log.d(TAG, e.getMessage());
		} 
		
		return ltime;
	}
	
}
